package com.mall.controller.portal;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.mall.common.ServerResponse;
import com.mall.service.IProductService;

@Controller
@RequestMapping("/product/")
public class ProductController {
	
	@Autowired
	private IProductService productService;
	
	@RequestMapping("/detail")
	@ResponseBody
	public ServerResponse getProductDetail(Integer productId){
		return productService.getProductDetail(productId);
	}
	
	@RequestMapping("/list")
	@ResponseBody
	public ServerResponse getProductList(@RequestParam(value="categoryId",required=false)Integer categoryId,
										 @RequestParam(value="keyword",required=false)String keyword,
										 @RequestParam(value="pageNum",defaultValue="1")int pageNum,
										 @RequestParam(value="pageSize",defaultValue="10")int pageSize,
										 @RequestParam(value="orderBy",defaultValue="")String orderBy){
		return  productService.getProductList(keyword,categoryId,pageNum,pageSize,orderBy);
		
	}
	
}
